﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using BaseData;
using BaseLib.Helper;
using BaseUtility;
using Newtonsoft.Json;
namespace WebUI.Ashx.App
{
    /// <summary>
    /// Exit 的摘要说明
    /// </summary>
    public class Exit : Base, IHttpHandler
    {
        private readonly AccClass _accId = new AccExts(new GetAccType().Parse(Request.QueryString["url"])).Instances;
        public void ProcessRequest(HttpContext context)
        {
            var flagStatus = 0;
            var messages = new StringBuilder();
            try
            {
                AccCookies.Clear(_accId.Type);
                messages.AppendLine("退出成功！");
            }
            catch (Exception err)
            {
                flagStatus = -1;
                messages.AppendLine(err.Message);
            }
            finally
            {
                var msg = new MsgErr
                {
                    error = flagStatus,
                    action = "Exit.ashx",
                    method = context.Request.HttpMethod,
                    message = new StringBuilder(messages.ToString()),
                };
                context.Response.Write(msg.ObjectsToJson());
                context.Response.ContentType = "text/plain";
            }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}